<!DOCTYPE html>
<html lang="zh" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro" xmlns:th="http://www.thymeleaf.org">
<meta charset="utf-8">
<link rel="stylesheet" th:href="@{/css/bootstrap.min.css}"/>
<link rel="stylesheet" th:href="@{/css/font-awesome.min.css}"/>
<!-- bootstrap-table 表格插件样式 -->
<link rel="stylesheet" th:href="@{/ajax/libs/bootstrap-table/bootstrap-table.min.css}"/>
<link rel="stylesheet" th:href="@{/ajax/libs/bootstrap-treetable/bootstrap-treetable.css}"/>
<link rel="stylesheet" th:href="@{/ajax/libs/bootstrap-table/extensions/columns/bootstrap-table-fixed-columns.css}"/>
<link rel="stylesheet" th:href="@{/css/animate.css}"/>
<link rel="stylesheet" th:href="@{/css/style.css}"/>
<link rel="stylesheet" th:href="@{/ajax/libs/select/select2.css}"/>
<link rel="stylesheet" th:href="@{/ruoyi/css/ry-ui.css}"/>
<link rel="stylesheet" th:href="@{/css/orgstyle.css}"/>


<body class="">
<div class="nav left">
    <div class="orglist" id="approverList">
        <h3>评价人</h3>
        <ul>
            <li th:each="approver:${approverList}"
                th:onclick="'javascript:showPreview(\''+${approver.approverCode}+'\',\''+${approver.id}+'\',\''+${approver.approverStatus}+'\',this);'">
                <p th:text="${approver.approverCode}"></p>
            </li>
        </ul>
    </div>
</div>

<div class="content right">
    <div class="tabPanel">
        <div class="nav_test">
            <h3 id="orgDeptProNameKey">评价信息</h3>
        </div>

        <div class="panes">
            <div class="pane" style="display:block;">
                <div class="pane_mokuai" id="orgDept">
                    <div id="xq">
                        鼠标悬浮显示详情框
                    </div>
                    <table class="table table-striped" id="table">
                        <!--在此处填充表格数据-->
                    </table>
                </div>
            </div>
        </div>
    </div>
</div>
<div th:include="include::footer"></div>
<script th:src="@{/ajax/libs/select/select2.js}"></script>
<script th:inline="javascript">

    var prefix = ctx + "zzjx/pefctasstable";

    /**
     * 展示用户评价信息
     * approverCode 办理人员工号
     **/
    function showPreview(approverCode, id, approverStatus, $el) {
        var tableId = [[${table.id}]];
        if (approverStatus == "1") {
            $.modal.alertWarning(approverCode + "该评价人未评价");
            return false;
        }
        $.modal.loading("稍等");
        $.ajax({
            url: prefix + "/previewForLdzhpj",
            type: "GET",
            data: {"tableId": tableId, "id": id, "approverCode": approverCode},
            dataType: "JSON",
            success: function (result) {
                $.table.destroy("table");
                //构建表格
                buildTable($('#table'), result);
                $.modal.closeLoading();
            },
            error: function () {
                $.modal.closeLoading();
                $.modal.alertError("加载信息失败!");
            }
        })
        $($el).addClass("selected").siblings().removeClass("selected");
    }

    /**
     * 构建预览信息表格
     * @param $el        table对象
     * @param list        行数据
     */
    function buildTable($el, list) {
        var columns = [
            [{
                field: "id",
                title: "ID",
                visible: false,
                rowspan: 2,
                colspan: 1
            }, {
                field: "target",
                title: "分数",
                visible: false,
                rowspan: 2,
                colspan: 1
            }, {
                field: 'indName',
                title: '被评价部门',
                rowspan: 2,
                colspan: 1,
                width: 15
            }, {
                field: 'mydpjAvg',
                title: '满意度评价结果',
                rowspan: 2,
                colspan: 1,
                width: 10
            }, {
                field: 'gzjhTableId',
                title: '重点工作评价结果',
                rowspan: 2,
                colspan: 1,
                width: 10,
                formatter: function (value, row, index) {
                    if (value == "" || typeof (value) == "undefined") {
                        return "";
                    } else {
                        return '<a  onclick="viewResult(\'' + value + '\',\'zdgz\')" >查看</a>';
                    }
                }
            }, {
                field: 'fileList',
                title: '工作计划完成情况',
                rowspan: 2,
                colspan: 1,
                width: 20,
                formatter: function (value, row, index) {
                    if (value == "" || typeof (value) == "undefined") {
                        return "";
                    } else {
                        var html = ""
                        var l = value.length;
                        if (l > 0) {
                            for (var i = 0; i < l; i++) {
                                html += "<a onclick='downloadFile(\"" + value[i].filePath + "\",\"" + value[i].fileName + "\")'>" + value[i].fileName + "</a>";
                                html += "<br>";
                            }
                        }
                        return html;
                    }
                }
            }, {
                field: 'fmqdKf',
                title: '负面清单扣分情况',
                rowspan: 2,
                colspan: 1,
                width: 20/*,
                    formatter: function (value, row , index) {
                        var id = row.id;
						var projectId = row.projectId;
                        return '<a  onclick="viewResult2(\''+projectId+'\',\'fmqd\')" >查看</a>';
                    }*/
            }, {
                title: '综合评价',
                align: 'center',
                colspan: 5,
                rowspan: 1,
                width: 25
            }],
            [{
                field: 'resultYx',
                title: '优秀',
                align: 'center',
                formatter: function (value, row, index) {
                    debugger
                    var name = "result" + row.id;
                    var target = row.target;
                    if (target == "5") {
                        return "<input type='radio' disabled value='5' name='" + name + "' checked>";
                    } else {
                        return "<input type='radio' disabled value='5' name='" + name + "'>"
                    }
                }
            }, {
                field: 'resultLh',
                title: '良好',
                align: 'center',
                formatter: function (value, row, index) {
                    var name = "result" + row.id;
                    var target = row.target;
                    if (target == "4.5") {
                        return "<input type='radio' disabled value='4.5' name='" + name + "' checked>";
                    } else {
                        return "<input type='radio' disabled value='4.5' name='" + name + "'>"
                    }
                }
            }, {
                field: 'resultYb',
                title: '一般',
                align: 'center',
                formatter: function (value, row, index) {
                    var name = "result" + row.id;
                    var target = row.target;
                    if (target == "4") {
                        return "<input type='radio' disabled value='4' name='" + name + "' checked>";
                    } else {
                        return "<input type='radio' disabled value='4' name='" + name + "'>"
                    }
                }
            }, {
                field: 'resultDgj',
                title: '待改进',
                align: 'center',
                formatter: function (value, row, index) {
                    var name = "result" + row.id;
                    var target = row.target;
                    if (target == "3") {
                        return "<input type='radio' disabled  value='3' name='" + name + "' checked>";
                    } else {
                        return "<input type='radio' disabled  value='3' name='" + name + "'>"
                    }
                }
            }, {
                title: '不合格',
                field: 'resultBhg',
                align: 'center',
                formatter: function (value, row, index) {
                    var name = "result" + row.id;
                    var target = row.target;
                    if (target == "2") {
                        return "<input type='radio' disabled value='2' name='" + name + "' checked>";
                    } else {
                        return "<input type='radio' disabled value='2' name='" + name + "'>"
                    }
                }
            }]
        ];

        //构建表格
        $el.bootstrapTable('destroy').bootstrapTable({
            columns: columns,
            data: list,
            search: false,
            showSearch: false,
            showRefresh: false,
            showToggle: false,
            showColumns: false,
            showExport: false,                     //是否显示导出
            height: 600,
            pagination: false,
            modalName: "考核指标"
        });
    }

    //表格超出宽度鼠标悬停显示td内容
    function paramsMatter(value, row, index, field) {
        var span = document.createElement('span');
        span.setAttribute('title', value);
        span.innerHTML = value;
        return span.outerHTML;
    }

    //td宽度以及内容超过宽度隐藏
    function formatTableUnit(value, row, index) {
        return {
            css: {
                "white-space": 'nowrap',
                "text-overflow": 'ellipsis',
                "overflow": 'hidden'
            }
        }
    }

    function bding() {
        $("td").mouseover(function (e) {
            var a = $(this).html();
            if (a.indexOf("<input") != -1) {
                a = $(this).find("input").val();
            }
            if (a.length < 7) {
                return;
            }
            $("#xq").html(a);
            $("#xq").css({"position": "absolute", "top": e.pageY + 15, "left": e.pageX - 75}).show();
        });
        $("td").mousemove(function (e) {
            $("#xq").css({
                "position": "absolute",
                "opacity": "0.7",
                "background-color": "666",
                "top": e.pageY + 15,
                "left": e.pageX - 75
            });
        });
        $("td").mouseout(function () {
            $("#xq").hide();
        });
    }

    /**
     * 查看
     * @param id
     * @param type
     */
    function viewResult(id, type) {
        if (type == "zdgz") {
            var url = prefix + "/detail/" + id + "/0";
            openFull("重点工作表单详情", url);
        }
    }

    // 弹出层全屏
    openFull = function (title, url, width, height) {
        //如果是移动端，就使用自适应大小弹窗
        if (navigator.userAgent.match(/(iPhone|iPod|Android|ios)/i)) {
            width = 'auto';
            height = 'auto';
        }
        if ($.common.isEmpty(title)) {
            title = false;
        }
        ;
        if ($.common.isEmpty(url)) {
            url = "/404.html";
        }
        ;
        if ($.common.isEmpty(width)) {
            width = 800;
        }
        ;
        if ($.common.isEmpty(height)) {
            height = ($(window).height() - 50);
        }
        ;
        var index = layer.open({
            type: 2,
            area: [width + 'px', height + 'px'],
            fix: false,
            //不固定
            maxmin: true,
            shade: 0.3,
            title: title,
            content: url,
            btn: ['关闭'],
            // 弹层外区域关闭
            shadeClose: true,
            cancel: function (index) {
                return true;
            }
        });
        layer.full(index);
    }

    function downloadFile(id, name) {
        window.location.href = ctx + "zzjx/projectSysfile/downloadFile?filePath=" + id + "&fileName=" + name;
    }
</script>
</body>
</html>
